package cn.yonyong.base.project.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Describtion 页面跳转，大概主功能
 * @Author yonyong
 * @Date 2019/9/6 11:18
 * @Version 1.0.0
 **/
@Api(value = "/main", tags = "main接口")
@Controller
@RequestMapping("main")
public class PageController {

    @ApiOperation(value = "主页面")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页码", required = true, dataType = "int", paramType = "path"),
            @ApiImplicitParam(name = "row", value = "记录数", required = true, dataType = "int", paramType = "path"),
    })
    //produces = "application/json;charset=utf-8" responsebody返回在页面上有中文乱码，加上这个参数就可以解决，不需要在其他地方加任何配置
    @RequestMapping(value = "get/{page}/{row}",method = RequestMethod.GET,produces = "application/json;charset=utf-8")
    @ResponseBody
    public String mainpage(@PathVariable("page")int page, @PathVariable("row")int row){
        System.out.println(page);
        System.out.println(row);
        return "当前查看第"+page+"页 第"+row+"行";
    }

    @ApiOperation(value = "前往文件处理页面")
    @RequestMapping(value = "toFile",method = RequestMethod.GET,produces = "application/json;charset=utf-8")
    public String toFile(){
        return "file/file";
    }

    @ApiOperation(value = "前往文件处理页面,网上案例")
    @RequestMapping(value = "toDemo",method = RequestMethod.GET,produces = "application/json;charset=utf-8")
    public String toFileFromNet(){
        return "file/fromNet";
    }

    @ApiOperation(value = "ztree简单")
    @RequestMapping(value = "departTree",method = RequestMethod.GET)
    private String toDepartTree(){
        return "tree/departTree";
    }

    @ApiOperation(value = "部门树outlook风格")
    @RequestMapping(value = "departTree2",method = RequestMethod.GET)
    private String toDepartTree2(){
        return "tree/departTree2";
    }

    @ApiOperation(value = "部门树原始风格")
    @RequestMapping(value = "departTree3",method = RequestMethod.GET)
    private String toDepartTree3(){
        return "tree/departTree3";
    }
}
